package com.sen.rbac.service;

import com.sen.common.common.bo.SysAccountBO;
import com.sen.common.common.response.PageVo;
import com.sen.rbac.dto.SysAccountDto;
import com.sen.rbac.exception.RbacException;
import com.sen.rbac.vo.SysAccountVO;
import com.sen.rbac.vo.SysRoleVO;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author esjiang
 */
public interface AccountService {

    /**
     * 根据账户名查询账户信息
     * @param userName
     * @param tenantCode
     * @param entityType
     * @return
     * @throws RbacException
     */
    SysAccountBO selectAccountByUserName(String userName, String tenantCode, String entityType) throws RbacException;

    /**
     * 新增
     * @param accountDto
     * @return
     */
    @Transactional(rollbackFor = RuntimeException.class)
    boolean addAccount(SysAccountDto accountDto);

    /**
     * 修改
     * @param accountDto
     * @return
     */
    @Transactional(rollbackFor = RuntimeException.class)
    boolean updateAccount(SysAccountDto accountDto);

    /**
     * 删除
     * @param userName
     * @return
     */
    @Transactional(rollbackFor = RuntimeException.class)
    boolean deleteAccount(String userName);

    /**
     * 列表分页查询
     * @param accountDto
     * @return
     */
    PageVo<SysAccountVO> list(SysAccountDto accountDto);

    /**
     * 重置密码
     * @param userName
     * @return
     * @throws RbacException
     */
    @Transactional(rollbackFor = RuntimeException.class)
    boolean resetPassword(String userName) throws RbacException;

    /**
     * 唯一性校验
     * @param userName
     * @return
     */
    boolean checkUniqueAccount(String userName);

    /**
     * 启用停用
     * @param userName
     * @param enable
     * @return
     * @throws RbacException
     */
    @Transactional(rollbackFor = RuntimeException.class)
    boolean enableAccount(String userName, String enable) throws RbacException;

    /**
     * 修改密码
     * @param sysAccountDto
     * @return
     */
    boolean updatePassword(SysAccountDto sysAccountDto);

    /**
     * 账户关联角色
     * @param userName
     * @param roleCodes
     * @return
     */
    boolean relatedRole(String userName, List<String> roleCodes);

    /**
     * 查询用户关联的角色
     * @param userName
     * @return
     */
    List<SysRoleVO> getRolesByUserName(String userName);

    SysAccountBO selectAccountByUserName(String userName);

}
